home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dr. Windows 3
/
dr win3.zip
/
dr win3
/
PROGRAMR
/
OLE2BOOK.ZIP
/
CHAP11.ZIP
/
CHAP11
/
COSCHMOO
/
IADVSINK.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-06-13
|
8KB
|
404 lines
/*
* IADVSINK.CPP
*
* Implementation of the CPolylineAdviseSink and CImpIAdviseSink interfaces
* for Component Schmoo. CPolylineAdviseSink moved here from polyline.cpp
* to live with all the advise stuff.
*
* IAdviseSink is implemented as a stand-alone object since no other piece
*
*
* Copyright (c)1993 Microsoft Corporation, All Rights Reserved
*
* Kraig Brockschmidt, Software Design Engineer
* Microsoft Systems Developer Relations
*
* Internet : kraigb@microsoft.com
* Compuserve: >INTERNET:kraigb@microsoft.com
*/
#include "coschmoo.h"
/*
* CPolylineAdviseSink::CPolylineAdviseSink
* CPolylineAdviseSink::~CPolylineAdviseSink
*
* Constructor Parameters:
* pv LPVOID to store in this object
* punkOuter LPUNKNOWN for IUnknown member delegation
*/
CPolylineAdviseSink::CPolylineAdviseSink(LPVOID pv, LPUNKNOWN punkOuter)
{
m_cRef=0;
m_pv=pv;
m_punkOuter=punkOuter;
return;
}
CPolylineAdviseSink::~CPolylineAdviseSink(void)
{
return;
}
/*
* CPolylineAdviseSink::QueryInterface
* CPolylineAdviseSink::AddRef
* CPolylineAdviseSink::Release
*
* Purpose:
* IUnknown members for this IPolylineAdviseSink implementations.
*/
STDMETHODIMP CPolylineAdviseSink::QueryInterface(REFIID riid, LPVOID FAR *ppv)
{
return m_punkOuter->QueryInterface(riid, ppv);
}
STDMETHODIMP_(ULONG) CPolylineAdviseSink::AddRef(void)
{
++m_cRef;
return m_punkOuter->AddRef();
}
STDMETHODIMP_(ULONG) CPolylineAdviseSink::Release(void)
{
--m_cRef;
return m_punkOuter->AddRef();
}
/*
* CPolylineAdviseSink::OnPointChange
*
* Purpose:
* Informs the document that the polyline added or removed a point.
*
* Parameters:
* None
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CPolylineAdviseSink::OnPointChange(void)
{
LPCDocument pDoc=(LPCDocument)m_pv;
pDoc->FDirtySet(TRUE);
return;
}
/*
* CPolylineAdviseSink::OnSizeChange
*
* Purpose:
* Informs the document that the polyline changed size.
*
* Parameters:
* None
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CPolylineAdviseSink::OnSizeChange(void)
{
LPCSchmooDoc pDoc=(LPCSchmooDoc)m_pv;
RECT rc;
DWORD dwStyle;
HWND hWnd;
/*
* Polyline window is informing us that it changed size in
* response to setting it's data. Therefore we have to
* size ourselves accordingly but without moving the screen
* position of the polyline window.
*/
pDoc->m_fNoSize=TRUE;
//Set the document window size.
pDoc->m_pPL->Window(&hWnd);
GetWindowRect(hWnd, &rc);
InflateRect(&rc, 8, 8);
//Adjust for a window sans menu
dwStyle=GetWindowLong(pDoc->m_hWnd, GWL_STYLE);
AdjustWindowRect(&rc, dwStyle, FALSE);
SetWindowPos(pDoc->m_hWnd, NULL, 0, 0, rc.right-rc.left
, rc.bottom-rc.top, SWP_NOMOVE | SWP_NOZORDER);
if (NULL!=pDoc->m_pAdv)
pDoc->m_pAdv->OnSizeChange(pDoc, &rc);
pDoc->m_fNoSize=FALSE;
pDoc->FDirtySet(TRUE);
return;
}
/*
* CPolylineAdviseSink::OnColorChange
*
* Purpose:
* Informs the document that the polyline data changed a color.
*
* Parameters:
* None
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CPolylineAdviseSink::OnColorChange(void)
{
LPCSchmooDoc pDoc=(LPCSchmooDoc)m_pv;
pDoc->FDirtySet(TRUE);
return;
}
/*
* CPolylineAdviseSink::OnLineStyleChange
*
* Purpose:
* Informs the document that the polyline changed its line style.
*
* Parameters:
* None
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CPolylineAdviseSink::OnLineStyleChange(void)
{
LPCSchmooDoc pDoc=(LPCSchmooDoc)m_pv;
pDoc->FDirtySet(TRUE);
return;
}
/*
* CImpIAdviseSink::CImpIAdviseSink
* CImpIAdviseSink::~CImpIAdviseSink
*
* Parameters (Constructor):
* pObj LPVOID of the object we're in.
* punkOuter LPUNKNOWN for delegation of IUnknown members.
*/
CImpIAdviseSink::CImpIAdviseSink(LPVOID pObj, LPUNKNOWN punkOuter)
{
m_cRef=0;
m_pObj=pObj;
m_punkOuter=punkOuter;
return;
}
CImpIAdviseSink::~CImpIAdviseSink(void)
{
return;
}
/*
* CImpIAdviseSink::QueryInterface
* CImpIAdviseSink::AddRef
* CImpIAdviseSink::Release
*
* Purpose:
* IUnknown members for CImpIAdviseSink object.
*/
STDMETHODIMP CImpIAdviseSink::QueryInterface(REFIID riid, LPVOID FAR *ppv)
{
return m_punkOuter->QueryInterface(riid, ppv);
}
STDMETHODIMP_(ULONG) CImpIAdviseSink::AddRef(void)
{
++m_cRef;
return m_punkOuter->AddRef();
}
STDMETHODIMP_(ULONG) CImpIAdviseSink::Release(void)
{
--m_cRef;
return m_punkOuter->AddRef();
}
/*
* IAdviseSink::OnDataChange
*
* Purpose:
* Notifes the advise sink that data changed in a data object. On
* this message you may request a new data rendering and update your
* displays as necessary.
*
* Parameters:
* pFEIn LPFORMATETC describing format that changed
* pSTM LPSTGMEDIUM providing the medium in which the data
* is provided.
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CImpIAdviseSink::OnDataChange(LPFORMATETC pFEIn
, LPSTGMEDIUM pSTM)
{
LPCSchmooDoc pDoc=(LPCSchmooDoc)m_pObj;
/*
* This code copied from former CPolylineAdviseSink::OnDataChange.
* The only advise we asked for was on the Polyline native format
* which is all we'll be notified for.
*/
if (NULL!=pDoc->m_pAdv)
pDoc->m_pAdv->OnDataChange(pDoc);
pDoc->FDirtySet(TRUE);
return;
}
/*
* IAdviseSink::OnViewChange
*
* Purpose:
* Notifes the advise sink that presentation data changed in the data
* object to which we're connected providing the right time to update
* displays using such presentations.
*
* Parameters:
* dwAspect DWORD indicating which aspect has changed.
* lindex LONG indicating the piece that changed.
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CImpIAdviseSink::OnViewChange(DWORD dwAspect, LONG lindex)
{
return;
}
/*
* IAdviseSink::OnRename
*
* Purpose:
* Informs the advise sink that an IOleObject has been renamed, primarily
* when its linked.
*
* Parameters:
* pmk LPMONIKER providing the new name of the object
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CImpIAdviseSink::OnRename(LPMONIKER pmk)
{
return;
}
/*
* IAdviseSink::OnSave
*
* Purpose:
* Informs the advise sink that the OLE object has been saved
* persistently. The primary purpose of this is for containers that
* want to make optimizations for objects that are not in a saved
* state, so on this you have to disable such optimizations.
*
* Parameters:
* None
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CImpIAdviseSink::OnSave(void)
{
return;
}
/*
* IAdviseSink::OnClose
*
* Purpose:
* Informs the advise sink that the OLE object has closed and is
* no longer bound in any way. On this you typically change state
* variables and redraw shading, etc.
*
* Parameters:
* None
*
* Return Value:
* None
*/
STDMETHODIMP_(void) CImpIAdviseSink::OnClose(void)
{
return;
}